package cn.xiu.drugstore.service.impl;

import java.util.List;
import cn.xiu.drugstore.dao.CustomerDao;
import cn.xiu.drugstore.dao.impl.CustomerDaoImpl;
import cn.xiu.drugstore.pojo.Customer;
import cn.xiu.drugstore.service.CustomerService;
/**
 * 顾客业务功能实现类
 * @author 陈亚鹏
 *
 */
public class CustomerServiceImpl implements CustomerService {
	CustomerDao dao=new CustomerDaoImpl();
	@Override
	public List<Customer> printAllCustomer() {
		try {
			return dao.queryAllCustomer();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Customer CustomerInfo(int custId) {
		try {
			return dao.queryCustomerById(custId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@Override
	public boolean registerCustomer(Customer customer) {
		CustomerDao nd = new CustomerDaoImpl();
		int result = -1;
		try {
			result = nd.add(customer);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (result > 0) {
			return true;
		} else {
			return false;
		}
	}
	/**
	 * 删除顾客
	 */
	@Override
	public boolean deleteCustomer(int id) {
		CustomerDao nd = new CustomerDaoImpl();
		int result = -1;
		try {
			result = nd.deleteCustomer(id);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (result > 0) {
			return true;
		} else {
			return false;
		}
	}
}
